//******************************************************************************************
// filename windows.h
// header file for windows class
// windows inherit form QMainWindow
// it is the main window
//*****************************************************************************************
#ifndef WINDOW_H
#define WINDOW_H

#include <QtGui>
#include <poppler-qt4.h>
#include "documentwidget.h"
#include "pagespinbox.h"
#include "fastnav.h"
#include "fastviewwidget.h"
#include "thumbnails.h"

#include <iostream>

class Window : public QMainWindow
{
    Q_OBJECT

  public:
   Window(QWidget *parent = 0);
   // sie hint
   QSize sizeHint() const { return QSize(800, 600); }

  protected:
    // event filter
    // for mouse move tracking for each child
     bool eventFilter(QObject *obj, QEvent *event);
     // move event
     void mouseMoveEvent (QMouseEvent *);

  private slots:

     // slots to open File
     void openFile();
     // slots to resuze page
     void scaleDocument(int index);
     // slots to swith between nomarl and fast nav
     void switchMode();
     // slots to swith two view bettwen Fast Nav 
     void switchFastNav();
     // slots to show sideBar
     void showSideBar();
     // slots to show page from fastNav
     void showPageFromFastNav(int pageNumber);
     // slots to show Page from sidebar
     void showPageFromSidebar(int pageNumber);
     // slot to update sideBar
     void updateSideBar(int index);
     
     void beginTest();
     void abortTest();
     void setTest();
     void findTarget(int pageNumber);
     //void prevHandle();
     void enablePageBox();
     
  private:
     DocumentWidget *documentWidget;
     FastNav *fastNavPanel;
     FastViewWidget *fastViewWidget;
     ThumbnailsDock * thumbnailsDock;
     QString lastPath;
     QString fileName;
     int viewMode;
     bool showSidebar;
     QVector<qreal> scaleFactors;
     // function to set actions
     void setActions();
     // function set menu
     void setMenu();
     // function to set tool bar
     void setToolBar();

     // actions used in this widget
     QAction *openAction;
     QAction *exitAction;
     QAction *setTestAction;
     QAction *showPageBoxAction;
     QAction *enablePageBoxAction;
     
     // child widgets
     QSpinBox *pageSpinBox;
     QComboBox *scaleComboBox;
     QPushButton *fastNavButton;
     QPushButton *thumbBarButton;
     QPushButton *testButton;
     QPushButton *abortButton;
     QStackedWidget * widgetStack;
     QDockWidget * sideBar;
   
     // dialog to show target page preivew
     QDialog *dialog;
     
     
     // following varibales are used for get testing data
     double travelDistance;
     bool startTest;
     QPointF last;
     
     int targetPage;
     // 0 for normal mode
     // 1 for thumb mode
     // 2 for fastNav mode
     // 3 for free mode
     int testMode;

     int testStartPage;
     int testStart;
     
     int totalTestTime;
     int docWidgetTime;
     int thumbnailTime;
     int fastNavTime;
     int fastViewTime;
     QTime timer;
     
     //priavte func

};

#endif
